package org.zpmis.domain.project.vo;

import lombok.Data;
import org.zpmis.domain.project.model.TaskTransferLog;

import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
public class TaskTransferLogVo implements Serializable {
    /**
     * 主键id
     */
    private Long id;

    /**
     * 任务id
     */
    private Long taskId;

    /**
     * 指派人id
     */
    private Long assignId;

    /**
     * 指派人姓名
     */
    private String assignName;

    /**
     * 被被指派人姓名
     */
    private String receiverName;

    /**
     * 被指派人id
     */
    private Long receiverId;

    /**
     * 指派时间
     */
    private String assignTime;

    /**
     * 描述
     */
    private String description;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String updateTime;

    public TaskTransferLogVo(TaskTransferLog taskTransferLog) {
        this.id = taskTransferLog.getId();
        this.taskId = taskTransferLog.getTaskId();
        this.assignId = taskTransferLog.getAssignId();
        this.assignName = taskTransferLog.getAssignName();
        this.receiverName = taskTransferLog.getReceiverName();
        this.receiverId = taskTransferLog.getReceiverId();
        this.assignTime = taskTransferLog.getAssignTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(taskTransferLog.getAssignTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.description = taskTransferLog.getDescription();
        this.createTime = taskTransferLog.getCreateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(taskTransferLog.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.updateTime = taskTransferLog.getUpdateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(taskTransferLog.getUpdateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }
}